package com.xjlsoft.weather.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjlsoft.weather.dto.PageDto;
import com.xjlsoft.weather.dto.ResultEntity;
import com.xjlsoft.weather.dto.WeatherDataQueryDto;
import com.xjlsoft.weather.entity.QueryLog;
import com.xjlsoft.weather.enums.ResultCodeEnum;
import com.xjlsoft.weather.service.QueryLogService;
import com.xjlsoft.weather.util.ResultUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/querylog")
@Api(tags = "请求日志数据接口")
public class QueryLogController {
	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(UserController.class);


	
	@Autowired
	private QueryLogService queryLogService;
	/**
	 * 按条件查询地面数据接口 <br/>
	 * json格式 传递参数
	 * 
	 * @param WeatherDataQueryDto
	 *            查询参数
	 * @throws Exception
	 * 
	 */
	@ApiOperation(value = "按条件分页查询 请求日志  数据接口", notes = "分页查询  请求日志   {  \"current\":1,  \"dateEnd\": \"2020-08-15 00:00:00\",  \"dateStart\": \"2020-08-01 00:00:00\",  \"size\":10} ")
	@RequestMapping(value = "/getQueryLogByDto", method = RequestMethod.POST)
	public Object getListByDto(@RequestBody WeatherDataQueryDto weatherDataQueryDto) throws Exception {

		PageDto<QueryLog> pageDto = new PageDto<QueryLog>();
		pageDto.setSize(weatherDataQueryDto.getSize());
		pageDto.setCurrent(weatherDataQueryDto.getCurrent());

		IPage<QueryLog> userIPage = queryLogService.getList(pageDto, weatherDataQueryDto);
		
		ResultEntity result = new ResultEntity(ResultCodeEnum.SUCCESS, userIPage, true);
		Map<String, Object> map = ResultUtil.resultMap(result);
		return map;
	};

	
	
}
